package com.xiumu.bean;

import cn.hutool.core.date.DateUtil;
import com.xiumu.bean.mapstruct.BeanCopyUtil;
import com.xiumu.bean.transform.dto.UserDTO;
import com.xiumu.bean.transform.dto.UserDTOPlus;
import com.xiumu.bean.transform.pojo.VblogUser;

/**
 * @Author xiumu
 * @Date 2020/10/24 16:28
 */
public class BeanUtilMain {
    /**
     * 创建对象,模拟数据
     * @return
     */
    public static VblogUser creatUser(){
        VblogUser user = new VblogUser();
        user.setId(1024L);
        user.setNickname("朽木");
        user.setPassword("123456");
        user.setUsername("亚索");
        user.setEmail("1234566665@qq.com");
        user.setUserface("xiumu.jpg");
        user.setEnabled(false);
        user.setRegTime(DateUtil.now());
        return user;
    }

    public static void main(String[] args) {
        //创建对象
        VblogUser vblogUser = creatUser();
        System.out.println(vblogUser);
        //使用MapStruct进行复制
        UserDTO userDTO = BeanCopyUtil.INSTANCE.userToUserDTO(vblogUser);
        System.out.println(userDTO);
        UserDTOPlus userDTOPlus = BeanCopyUtil.INSTANCE.userToUserPlus(vblogUser);
        System.out.println(userDTOPlus);
    }
}
